package ru.housewife.form;

/**
 * Form object for
 * @see ru.housewife.model.EatingMenuDishRecipe
 *
 * @author Alexander Troshanin
 */
public class EatingMenuDishRecipeForm implements Comparable<EatingMenuDishRecipeForm>{

    private long id;

    private EatingMenuForm eatingMenu;

    private CookingDishRecipeForm recipe;

    private int count = 1;

    public EatingMenuDishRecipeForm(long id, EatingMenuForm eatingMenu, CookingDishRecipeForm recipe) {
        this.id = id;
        this.eatingMenu = eatingMenu;
        this.recipe = recipe;
    }

    public long getId() {
        return id;
    }

    public EatingMenuForm getEatingMenu() {
        return eatingMenu;
    }

    public CookingDishRecipeForm getRecipe() {
        return recipe;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public boolean isUserRecipeOwner() {
        return eatingMenu.getUser().getId() == recipe.getOwnerId();
    }

    @Override
    public int compareTo(EatingMenuDishRecipeForm that) {
        return this.recipe.compareTo(that.recipe);
    }
}
